//南航明珠商城-过期商品管理.js
 function search(){
	     var productId=  document.getElementsByName("prodId")[0].value
	     if(productId!=''&&isNaN(productId)){ 
	         layer.layer.alert("输入的商品编号有误，请重新输入！");
	         return  ;
	     }
	     document.getElementsByName("prodId")[0].value=(document.getElementsByName("prodId")[0].value).trim(); 
 	     document.getElementsByName("proName")[0].value=(document.getElementsByName("proName")[0].value).trim(); 
         $("#page").val("1");
         $("#query_expire_product_form").submit();
	 }	
function toIsEmpty(){
    document.getElementsByName("proName")[0].value= "";
    document.getElementsByName("prodId")[0].value= "";
    document.getElementsByName("proType")[0].value= "";
    document.getElementsByName("merchantQo.id")[0].value= "";
    $("#startDate").val("");
    $("#endDate").val("");
}
function downProduct(productId){
	layer.confirm("确定要恢复该商品吗？",function(){
		layer.closeAll('dialog');
		var layer_load_window = layer.load(2); 
		 $.ajax({
			url : path + "/product/modify_product_down_expire",
			cache : false,
			type : 'post',
			data :{"productId":productId},
			success : function(message) {
				if(message == "200"){
					layer.msg('操作成功!',{icon:1,time:1000},function(){
						$("#query_expire_product_form").submit();
					});
				}else if(message == "500"){
					layer.alert("系统繁忙！");
				}else{
					layer.alert(message);
				}
			},complete: function(XMLHttpRequest, textStatus) {
				layer.close(layer_load_window);
			}
	  	});
	});
  }
//添加选中的商品ID
function addProduct(productId){
	var productIds = $("#productIds").val();
	var productIdArr = 	productIds.split(",");
	var exist = false;
	for(var i=0;i<productIdArr.length;i++){
		if(productIdArr[i] == productId){
			exist = true;
			break;
		}
	}
	if(!exist){
		if(productIds.length == 0){
			productIds = productIds + productId;
		}else{
			productIds = productIds + "," + productId;
		}
	}
	$("#productIds").val(productIds);
}

//删除商品ID
function deleteProduct(productId){
	var productIds = $("#productIds").val();
	var productIdArr = 	productIds.split(",");
	var result = "";
	for(var i=0;i<productIdArr.length;i++){
		if(productIdArr[i] != productId){
			if(result.length == 0){
				result = result + productIdArr[i];
			}else{
				result = result + "," + productIdArr[i];
			}
		}
	}
	$("#productIds").val(result);
}
/*查看*/
function look_product(title,url,w,h){
	        var index = layer.open({
	            type: 2,
	            title: title,
	            scrollbar: false,
	            content: url,
	            area: [w+'px', h+'px']
	        });
	    }
/*设置过期商品*/
function setNotBuyProduct(title,url,w,h){
	        var index = layer.open({
	            type: 2,
	            title: title,
	            scrollbar: false,
	            content: url,
	            area: [w+'px', h+'px']
	        });
	    }
function slimport(){
	 var form_path= $("#query_expire_product_form").attr("action");
    $("#query_expire_product_form").attr("action",path+"/product/query_excel_expire_product_list").submit(); 
    $("#query_expire_product_form").attr("action",form_path);
}